home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / cci / sil_main.c < prev   
C/C++ Source or Header  |  1992-01-23  |  3KB  |  125 lines

  1. /* --------------------------------------------------------------------------
  2.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  3.  *
  4.  * You can use and distribute this software under the terms of the licence
  5.  * you should have received along with this program.
  6.  * If not or if you want additional information, write to
  7.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  8.  * D-7500 Karlsruhe 1, Germany.
  9.  * --------------------------------------------------------------------------
  10.  */
  11. // **************************************************************************
  12. // Module sil_main                                           Juergen Uhl (ju)
  13. //
  14. // **************************************************************************
  15. // SOS schema implementation linker (sil)
  16. // **************************************************************************
  17.  
  18. #include <stream.h>
  19. #include "sys.h"
  20. #include "smg.h"
  21. #include "sos.h"
  22. #include "trc.h"
  23. #include "cci_err.h"
  24. #include "cci_use.h"
  25.  
  26. int main (int argc, char *argv[])
  27. {  T_INIT ("sil.out");
  28.    sos_init (argc, argv);
  29.  
  30.    if (argc < 2)
  31.    {  err_raise (err_USE, err_SIL_USAGE, NULL, FALSE);
  32.       T_EXIT(); exit (1);
  33.    }
  34.  
  35.    sos_String str = smg_String (argv[1]).make_String (TEMP_CONTAINER);
  36.    sos_Schema_module sm = sos_Schema_module::lookup (str);
  37.    str.destroy();
  38.  
  39.    if (sm == NO_OBJECT)
  40.    {  err_raise (err_USE, err_SIL_NO_SCHEMA, argv[1], FALSE);
  41.       T_EXIT(); exit (1);
  42.    }
  43.  
  44.    sos_Container sct = sm.container();
  45.    sct.open (WRITING, WAITING);
  46.  
  47.    cci_Schema_impl impl    = cci_Schema_impl::make_impl (sm);
  48.    sos_String_List ofs     = impl.get_object_files(),
  49.            libs    = impl.get_libraries(),
  50.            schemas = impl.get_schemas();
  51.  
  52.    for (int i = 2;  i < argc;  i++)
  53.    {  if (streql (argv[i], "-r"))
  54.       {  ofs.clear();
  55.      libs.clear();
  56.      schemas.clear();
  57.       }
  58.  
  59.       else if (streql (argv[i], "-a"))
  60.       {  str = sos_String::create (TEMP_CONTAINER);
  61.      smg_String tmp;
  62.       
  63.      while (++i < argc)
  64.      {  int          len    = strlen (argv[i]);
  65.         char         *arg   = argv[i],
  66.                 *tail2 = arg + len - 2;
  67.         sos_String_List list;
  68.  
  69.         if (len > 2 AND streql (".o", tail2))
  70.            list = ofs;
  71.         else if (len > 2 AND (streql (".a", tail2)
  72.                   OR arg[0] EQ '-' AND arg[1] EQ 'l'))
  73.            list = libs;
  74.         else if (len > 4 AND streql (".sos", tail2-2))
  75.         {  list = schemas;
  76.            arg  = strncpy (new (char[len-3]), arg, len - 4);
  77.            arg[len-4] = EOS;
  78.            tmp = smg_String (arg, SMG_TRANSFER);
  79.         }
  80.         else
  81.            break;
  82.  
  83.         str.assign_Cstring (arg);
  84.         if (NOT list.is_element (str))
  85.            list.append (sos_String::copy (str, sct));
  86.      }
  87.      -- i;
  88.      str.destroy();
  89.       }
  90.  
  91.       else if (streql (argv[i], "-p"))
  92.       {  agg_iterate (ofs, str)
  93.         cout << str << "\n";
  94.      agg_iterate_end (ofs, str);
  95.  
  96.      agg_iterate (libs, str)
  97.         cout << str << "\n";
  98.      agg_iterate_end (libs, str);
  99.  
  100.      agg_iterate (schemas, str)
  101.         cout << str << ".sos\n";
  102.      agg_iterate_end (schemas, str);
  103.       }
  104.  
  105.       else if (streql (argv[i], "-l"))
  106.       {  err_block 
  107.             impl.load();
  108.             cout << "...done\n";
  109.          err_exception
  110.             cout << err_last_raised() << "\n";
  111.         T_EXIT(); exit (1);
  112.          err_block_end
  113.       }
  114.  
  115.       else
  116.       {  err_raise (err_USE, err_SIL_USAGE, argv[i], FALSE);
  117.      T_EXIT(); exit (1);
  118.       }
  119.    }
  120.    sct.close ();
  121.  
  122.    T_EXIT ();
  123.    exit (0);
  124. }
  125.